import { defineStore } from 'pinia'
import { ref } from 'vue'
import { axiosService } from '@/http/sever'
import { showNotify } from '@nutui/nutui'

export const useUserStore = defineStore(
    'user',
    () => {
        const userInfo = ref({})

        const getUserInfo = async () => {
            try {
                const res = await axiosService.get('/api/User/index')
                userInfo.value = res.data.user
            } catch (err) {
                showNotify.danger(err.msg)
            }
        }

        return { userInfo, getUserInfo }
    },
    {
        persist: true
    }
)
